package com.baizhi.service;

import com.baizhi.dao.UserDao;
import com.baizhi.entity.User;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;


@Service
@Transactional
public class UserServiceImpl implements UserService {
    @Resource
    private UserDao userDao;

    @Override
    public List<User> queryAllUser() {
       List<User> users = userDao.queryAllUser();
        System.out.println(users);
        return users;
    }

    @Override
    public int login(String username, String password) {
        List<User> users = userDao.queryAllUser();
        for (User user : users) {
            if(username.equals(user.getUsername())&&password.equals(user.getPassword())==true){
                return 1;
            }
        }
        return 2;
    }
}
